package controllayer;

import modellayer.Customer;
import modellayer.Invoice;
import dblayer.InvoiceDB;

public class InvoiceCTR {
	private InvoiceDB iDB;
	
	/**
	 *  Constructor initiating Invoice DB object 
	 */
	public InvoiceCTR() {
		iDB = new InvoiceDB();
	}
	
	/**
	 * createInvoice method creating and Invoice object and puts further to InvoiceDB which will insert it into the Database.
	 * If failure, this method throws an exception.
	 * 
	 * @param paymentDate
	 * @param amount
	 * @throws Exception
	 */
	public void createInvoice(String paymentDate, double amount) throws Exception 
	{
		Invoice i  = new Invoice(0, paymentDate, amount);
		iDB.insertInvoice(i);
	}
	
	public void insertInvoice(Invoice i) throws Exception
	{
		iDB.insertInvoice(i);
	}
}
